package com.lingyu.jsjx.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lingyu.jsjx.domain.TeachingResearch;
import com.lingyu.jsjx.service.ITeachingResearchService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 教研管理
 * @author ruoyi
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/teachingResearch")
public class TeachingResearchController extends BaseController
{
    @Autowired
    private ITeachingResearchService teachingResearchService;

    /**
     * 查询教研管理列表
     */
    @RequiresPermissions("jsjx:teachingResearch:list")
    @GetMapping("/list")
    public TableDataInfo list(TeachingResearch teachingResearch)
    {
        startPage();
        List<TeachingResearch> list = teachingResearchService.selectTeachingResearchList(teachingResearch);
        return getDataTable(list);
    }

    /**
     * 导出教研管理列表
     */
    @RequiresPermissions("jsjx:teachingResearch:export")
    @Log(title = "教研管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeachingResearch teachingResearch)
    {
        List<TeachingResearch> list = teachingResearchService.selectTeachingResearchList(teachingResearch);
        ExcelUtil<TeachingResearch> util = new ExcelUtil<TeachingResearch>(TeachingResearch.class);
        util.exportExcel(response, list, "教研管理数据");
    }

    /**
     * 获取教研管理详细信息
     */
    @RequiresPermissions("jsjx:teachingResearch:query")
    @GetMapping(value = "/{researchId}")
    public AjaxResult getInfo(@PathVariable("researchId") Long researchId)
    {
        return success(teachingResearchService.selectTeachingResearchByResearchId(researchId));
    }

    /**
     * 新增教研管理
     */
    @RequiresPermissions("jsjx:teachingResearch:add")
    @Log(title = "教研管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeachingResearch teachingResearch)
    {
//        SysDictData sysDictData = sysDictDataService.selectDictDataById(teachingResearch.getResearchTypeId());
//        switch (sysDictData.getDictValue()){
//            case "1":
//                teachingResearch.setResearchStatusId(96L);
//                break;
//            case "2":
//            case "3":
//                teachingResearch.setResearchStatusId(100L);
//                break;
//            case "4":
//                teachingResearch.setResearchStatusId(106L);
//                break;
//        }
        return toAjax(teachingResearchService.insertTeachingResearch(teachingResearch));
    }

    /**
     * 修改教研管理
     */
    @RequiresPermissions("jsjx:teachingResearch:edit")
    @Log(title = "教研管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeachingResearch teachingResearch)
    {
        return toAjax(teachingResearchService.updateTeachingResearch(teachingResearch));
    }

    /**
     * 删除教研管理
     */
    @RequiresPermissions("jsjx:teachingResearch:remove")
    @Log(title = "教研管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{researchIds}")
    public AjaxResult remove(@PathVariable Long[] researchIds)
    {
        return toAjax(teachingResearchService.deleteTeachingResearchByResearchIds(researchIds));
    }

    @GetMapping(value = "/queryCountByResearchType")
    public AjaxResult queryCountByResearchType(){
        return success(teachingResearchService.selectCountByResearchType());
    }

    @GetMapping(value = "/queryResearchTypeCount")
    public AjaxResult queryResearchTypeCount(){
        return success(teachingResearchService.selectResearchTypeCount());
    }
}
